package com.tianji.learning.controller;

/**
 * @Description LearningRecordController
 * @Author zhd
 * @Date 2024-12-15
 */

import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningLessonService;
import com.tianji.learning.service.LearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/learning-records")
@Api(tags = "学习记录的相关接口")
@RequiredArgsConstructor
@Slf4j
public class LearningRecordController {

	private final LearningRecordService recordService;

	private final ILearningLessonService lessonService;

	@ApiOperation("查询指定课程的学习记录")
	@GetMapping("/course/{courseId}")
	public LearningLessonDTO queryLearningRecordByCourse(
			@ApiParam(value = "课程id", example = "2") @PathVariable("courseId") Long courseId) {
		return recordService.queryLearningRecordByCourse(courseId);
	}

	@ApiOperation("提交学习记录")
	@PostMapping
	public void addLearningRecord(@RequestBody LearningRecordFormDTO formDTO) {
		recordService.addLearningRecord(formDTO);
	}
}
